<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title></title> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <!-- 
 <script type="text/javascript" src="Js/jquery.js"></script> -->
<!-- <script type="text/javascript" src="Js/jquery-1.9.0.min.js"></script> -->
	<script type="text/javascript" src="${pageContext.request.contextPath}/sys/style/js/jquery.min.js"></script>  
 <script type="text/javascript" src="${pageContext.request.contextPath}/Login/Js/login.js"></script> 
 <script type="text/javascript" src="${pageContext.request.contextPath}/sys/style/js/toastr.min.js"></script>
 <script type="text/javascript" src="${pageContext.request.contextPath}/Login/Js/jquery.validate.min.js?var1.14.0"></script>
 
 <link href="${pageContext.request.contextPath}/Login/css/login2.css" rel="stylesheet" type="text/css" /> 
 <link href="${pageContext.request.contextPath}/sys/style/css/toastr.css" rel="stylesheet" />

</head>

<body>
<h1><sup></sup></h1>

<div class="login" style="margin-top:50px;">
    
    <div class="header">
        <div class="switch" id="switch"><a class="switch_btn_focus" id="switch_qlogin" href="javascript:void(0);" tabindex="7">快速登录</a>
			<a class="switch_btn" id="switch_login" href="javascript:void(0);" tabindex="8">快速注册</a><div class="switch_bottom" id="switch_bottom" style="position: absolute; width: 64px; left: 0px;"></div>
        </div>
    </div>    
  
    
    <div class="web_qr_login" id="web_qr_login" style="display: block; height: 235px;">    

            <!--登录-->
            <div class="web_login" id="web_login">                        
               <div class="login-box">
    
            
			<div class="login_form">
				<form  action="${pageContext.request.contextPath}/login.action" name="loginform" accept-charset="utf-8" id="login_form" class="loginForm" method="post" onsubmit="return DLtijiao()" >
					<input type="hidden" name="did" value="0"/>
	                <input type="hidden" name="to" value="log"/>
                <div class="uinArea" id="uinArea">
	                <label class="input-tips" for="u">帐号：</label>
	                <div class="inputOuter" id="uArea">
	                    <span  id="tips"></span>
	                    <input type="text" id="UserId_log" name="login.a_userId" class="inputstyle" onblur="checkUserId()"/>
	                </div>
                </div>
                <div class="pwdArea" id="pwdArea">
                   <label class="input-tips" for="p">密码：</label> 
	               <div class="inputOuter" id="pArea">                    
	                    <input type="password" id="password_log" name="login.a_passwd" class="inputstyle"/>
	                </div>             
                </div>
                <div class="select">
	                 <input id="JiaoSe"  name="select1" type="hidden" value="" />
	                 <input id="a"  name="identify" type="radio" value="admin" onclick="check1(1)"/>管理员
	                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	                 <input id="a" name="identify" type="radio" value="employee" onclick="check1(0)" />员工
                 </div>
                <div style="padding-left:50px;margin-top:20px;">
                	<input type="submit" value="登 录" style="width:150px;" class="button_blue"/>
                </div>
              </form>
           </div>
           
            	</div>
               
            </div>
            <!--登录end-->
  </div>

  <!--注册-->
    <div class="qlogin" id="qlogin" style="display: none; ">
   
    <div class="web_login">
    <form onsubmit="return ZCtijiao()" action="${pageContext.request.contextPath}/register1" method="post"    accept-charset="utf-8"  >
	      <input type="hidden" name="to" value="reg"/>
		  <input type="hidden" name="did" value="0"/>
        <ul class="reg_form" id="reg-ul">
        <div id="userCu" class="cue">快速注册请注意格式</div>
                <li>
                	
                    <label for="user"  class="input-tips2">用户名：</label>
                    <div class="inputOuter2">
                        <input onBlur="checkUserId()"  type="text" id="user" name="login.a_name" maxlength="16" class="inputstyle2"/>
                    </div>
                    
                </li>
                
                <li>
                <label for="passwd" class="input-tips2">密码：</label>
                    <div class="inputOuter2">
                        <input onBlur="passwordd()" type="password" id="passwd"  name="login.a_passwdd2" maxlength="16" class="inputstyle2"/>
                    </div>
                    
                </li>
                <li>
                <label for="passwd2" class="input-tips2">确认密码：</label>
                    <div class="inputOuter2">
                        <input onBlur="querenmima()" type="password" id="passwd2" name="login.a_passwd" maxlength="16" class="inputstyle2" />
                    </div>
                    
                </li> 
         
                <li>
                 <label for="phone" class="input-tips2">手机号码：</label>
                    <div class="inputOuter2">
                         <input onBlur="phone()"  id="mobile" name="login.a_phone" type="text" required="required" class="inputstyle2" size="25"/><span style="color:#FF0000"> *</span> 
	                     <input id="zphone" type="button" value=" 发送手机验证码 " onClick="get_mobile_code(this);"  style="display: inline"/><br />	                    
                        <input  type="text" id="code" name="code"  placeholder="请输入验证码"  class="inputstyle3" onblur="validate_code(this)"/>
                    </div>
                   
                </li>
                
                <li>
                    <div class="inputArea">
                        <input type="submit" id="reg"  style="margin-top:10px;margin-left:85px;" class="button_blue" value="提交"/>
                        <input type="reset" id="reg"  style="margin-top:10px;margin-left:85px;" class="button_blue" value="重置"/></a>
                    </div>
                    
                </li><div class="cl"></div>
            </ul></form>
           
    
    </div>
    </div>
    <!--注册end-->
</div>

<script  type="text/javascript"  language="JavaScript"> 



 toastr.options.positionClass = 'toast-bottom-right'; //初始化 toastr 提示插件
			 /* toastr.success('提交数据成功');
				toastr.error('Error');
				toastr.warning('只能选择一行进行编辑');
				toastr.info('info'); */
				

function usernamee()
{
	 var userId= document.getElementById("user").value;
	 if(userId=="")
	 {
		toastr.error('用户名不能为空');
		return false;
	}
	return true;
	
}


function passwordd()
{
	var passwd= document.getElementById("passwd").value;
	if(passwd=="")
	{
	   toastr.error('密码不能为空');
	   return  false;
	}
	else
	{
		toastr.success('密码可用');
		return true;	
	}
}



function querenmima()
{
	 var passwd= 	   document.getElementById("passwd").value;
	 var querenwpass = document.getElementById("passwd2").value;
	 
	 if(querenwpass=="")
	 {
	 	 toastr.error('确认密码不能为空');
	 	return false;
	 }
	 
	 if(passwd==querenwpass)
	 {
	 	toastr.success('确认密码正确');
	 	return true;
	 }
	 else
	 {
	 	toastr.warning('确认密码与密码错误');
	 	return false;
	 }
}


function phone()
{
	var passwd= 	   document.getElementById("mobile").value;
	var b   = /^1[34578]\d{9}$/;
	if(passwd=="")
	{
		toastr.warning('手机号不能为空');
		return false;
	}
	
	if(passwd.replace(b,'') == '')
	{
		toastr.success('手机号正确');
		return true;
	}
	else
	{
		toastr.warning('手机号格式错误');
		return false;
	}
}



 function checkUserId()
 {
 	var userr = document.getElementById("user").value;
	var pp =1;
 	
 	if(usernamee()==false)
 	{
 		return false;
 	}
 	
 
	$.ajax
	(
			{
					async:false,
				
			        type:"POST",
			        
			        url:"/OrderSystem/checkId.action",
			
			        cache : false, 
	              
	                data:{"p":userr},
	                
	                dataType:"text",
				   
	                success:function(data)
	                {
	                	console.log(data);
	                    var obj = jQuery.parseJSON(data);
	                	
	                	if(obj[0].head.result==200)
	                	{
	                		toastr.error(obj[0].head.code);
	                		pp=0;
	                	}
	                	else if(obj[0].head.result==500) 
	                	{
	                		//可用
	                		toastr.success(obj[0].head.code);
	                		pp=1;
	                	}
	                },
	                
			       error:function()
			       {
			    	   console.log("500");
			    	   toastr.error('系统错误，请稍后登录');
			  		   pp=0;     		
			       }	
	
			}
	);	
	
	if(pp==1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
 
 
function ZCtijiao()
{
	if(checkUserId()&&usernamee()&&passwordd()&&querenmima()&&phone()&&validate_code(document.getElementById("code")))
	{
		 toastr.success('注册成功');
		return true;
	}
	else
	{
		return false;	
	}
} 
 
 
function DLtijiao()
{
	var JiaoSe = document.getElementById("JiaoSe").value;
	if( document.getElementById("UserId_log").value=="" || document.getElementById("password_log").value=="")
	{
		toastr.error('用户名或者密码不能为空');
		return false;	
	}
	else
	{
		if(JiaoSe=="")
		{
			toastr.error('请选择角色之后在登录');
			return false;
		}
		else
		{
			return true;
		}
	}	
}
		

//获取不同身份的带参值
function check1(i)
{    
	  document.getElementById("JiaoSe").value=i;	
}
  </script>
<script type="text/javascript" src="${pageContext.request.contextPath}/Login/Js/MobleVerify.js"></script> 
<div class="jianyi">
<%
	if("-1".equals(request.getParameter("msg")) );
	{
		out.print("<font color='#FF0000'>请先登录</font>");
	}
 %>
</div>
</body></html>
